import React, { Component } from "react";
// NavLink可以用来代替Link组件，在Link组件的基础上面，多加了一个导航高亮的效果
import { Route, Switch, NavLink } from "react-router-dom";

import "./07-style.css";

class Home extends Component {
  render() {
    return <div>这是home组件</div>;
  }
}

class About extends Component {
  render() {
    return <div>这是About组件</div>;
  }
}

class Mine extends Component {
  render() {
    return <div>这是Mine组件</div>;
  }
}

class App extends Component {
  render() {
    return (
      <>
        <h2>react-router-导航高亮</h2>
        <ul>
          <li>
            {/* 默认的类名是active */}
            <NavLink to="/" activeClassName="select" exact>
              首页
            </NavLink>
          </li>
          <li>
            <NavLink to="/about" activeClassName="select">
              关于页
            </NavLink>
          </li>
          <li>
            <NavLink to="/mine" activeClassName="select">
              我的页
            </NavLink>
          </li>
        </ul>

        <hr />

        <Switch>
          <Route path="/" component={Home} exact></Route>
          <Route path="/about" component={About}></Route>
          <Route path="/mine" component={Mine}></Route>
        </Switch>
      </>
    );
  }
}

export default App;
